﻿using System;

class Equation
{
    static void Main()
    {
        //Exercise 6.
        //Write a program that reads the coefficients a, b and c of a quadratic equation ax2+bx+c=0 and solves it 
        //(prints its real roots).

        Console.Write("Enter a: ");
        int a = int.Parse(Console.ReadLine());
        Console.Write("Enter b: ");
        int b = int.Parse(Console.ReadLine());
        Console.Write("Enter c: ");
        int c = int.Parse(Console.ReadLine());

        int d = (b * b) - (4 * a * c);  //defines the discriminant;

        if (d < 0)
        {
            Console.WriteLine("The quadratic equation does not have real roots.");
        }
        else
        {
            if (d == 0)
            {
                Console.WriteLine("The only root is: {0:0.00}", -(b / (2 * a)));
            }
            else
            {
                double result1 = ((-b) + Math.Sqrt(d)) / (2 * a);
                Console.WriteLine("The first root is: {0:0.00}", result1);
                double result2 = ((-b) - Math.Sqrt(d)) / (2 * a);
                Console.WriteLine("The second root is: {0:0.00}", result2); 
            }
        }
    }
}

